import { Button, Col, Row } from 'antd';
import React, { useState } from 'react';

import LocalInfo from '@/utils/localInfo';

import DeviceCheckButton from './DeviceCheckButton';
import DeviceInitModal from './DeviceInitModal';
import LogSetModal from './LogSetModal';
import ResetButton from './ResetButton';
import styles from './styles.module.less';

const Buttons = React.memo(() => {
  const [deviceInitModalOpen, setDeviceInitModalOpen] = useState(false);
  const [isLogModalOpen, setIsLogModalOpen] = useState(false);

  return (
    <>
      <Row>
        <Col>
          <div className={styles.InitializationButton1}>
            <Button
              className={styles.Button}
              type="primary"
              onClick={() => setDeviceInitModalOpen(true)}
              disabled={LocalInfo.getRoleId() === 2}
            >
              设备初始化
            </Button>
          </div>
        </Col>

        <Col
          style={{
            marginLeft: '90px',
          }}
        >
          <div className={styles.InitializationButton1}>
            <Button
              className={styles.Button}
              type="primary"
              onClick={() => setIsLogModalOpen(true)}
              disabled={LocalInfo.getRoleId() === 2}
            >
              设置日志等级
            </Button>
          </div>
        </Col>

        {/* <Col
          style={{
            marginLeft: '90px',
          }}
        >
          <div className={styles.InitializationButton1}>
            <Button
              type="default"
              className={styles.Button}
              onClick={() => setIsConfigureModalOpen(true)}
            >
              获取设备配置
            </Button>
          </div>
        </Col> */}

        <Col
          style={{
            marginLeft: '90px',
          }}
        >
          <DeviceCheckButton />
        </Col>

        <Col
          style={{
            marginLeft: '90px',
          }}
        >
          <ResetButton />
        </Col>
      </Row>

      <DeviceInitModal
        visible={deviceInitModalOpen}
        setVisible={setDeviceInitModalOpen}
      />

      <LogSetModal visible={isLogModalOpen} setVisible={setIsLogModalOpen} />
    </>
  );
});
Buttons.displayName = 'Buttons';
export default Buttons;
